package com.huaxinkai.mobile.service.impl;

import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import com.huaxinkai.mobile.entity.AccessToken;
import com.huaxinkai.mobile.entity.JsAPITicket;
import com.huaxinkai.mobile.service.IUpdateAccessTokenService;
import com.huaxinkai.service.impl.BaseService;

/**
 * 更新wechat  access_token service类
 * @author liuzh
 * @data 2017年1月2日下午12:46:17
 */
@Service
@Transactional
public class UpdateAccessTokenService extends BaseService implements IUpdateAccessTokenService{

	/**
	 * 新增token
	 * @param at
	 * @throws Exception
	 */
	@Override
	public void addAccessToken(AccessToken at) throws Exception{
		getCurrentSession();
		insert(at);
		
	}
	/**
	 * 更新token
	 * @param accessToken
	 * @throws Exception
	 */
	@Override
	public void updateToken(AccessToken accessToken)  throws Exception{
		getCurrentSession();
		update(accessToken);
	}
	/**
	 * 查AccessToken by  id
	 * @return
	 * @throws Exception
	 */
	@Override
	public AccessToken queryToken()  throws Exception{
		getCurrentSession();
		return (AccessToken) query(AccessToken.class, 1);
	}
	
	/**
	 * 查js ticke by  id
	 * @return
	 * @throws Exception
	 */
	@Override
	public JsAPITicket queryTicket()  throws Exception{
		getCurrentSession();
		return (JsAPITicket) query(JsAPITicket.class, 1);
	}
	/**
	 * 新增token
	 * @param at
	 * @throws Exception
	 */
	@Override
	public void addTicket(JsAPITicket ticket) throws Exception{
		getCurrentSession();
		insert(ticket);
		
	}
	/**
	 * 更新 js ticke 
	 * @return
	 * @throws Exception
	 */
	@Override
	public void updateTicket(JsAPITicket ticket)  throws Exception{
		getCurrentSession();
		update(ticket);
	}
	

}
